home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_18162.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  33 lines

  1. -- card: 18162 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10.     age = new_age;
  11.     weight = new_weight;
  12.  
  13. Here, the instance variables are assigned the values requested from the user in the foregoing scanf() function call.
  14.  
  15. Interestingly, assignments are expressions in C, as are function calls.  That is, the expression 'age=new_age' has a value; namely, the value which was assigned.  This means that assignments can be freely used within other expressions, such as 'weight = 4 * (age = new_age) / 7'.
  16.  
  17. Another important thing to notice is that we defined new automatic variables         new_age and new_weight instead of simply passing scanf() the addresses of the age and weight instance variables.  For reasons discussed later, TC's management of objects makes it dangerous to pass the address of an instance variable as an argument to certain functions*.
  18.  
  19. -- part contents for background part 27
  20. ----- text -----
  21. Macintosh memory management
  22.  
  23. -- part contents for background part 20
  24. ----- text -----
  25. Macintosh memory management - p123
  26.  
  27. -- part contents for background part 7
  28. ----- text -----
  29. 31
  30.  
  31. -- part contents for background part 29
  32. ----- text -----
  33. 38494